package com.extension.company.presenter.main;

import android.content.Context;

import com.extension.company.model.entity.HotDataListBean;
import com.extension.company.model.entity.ListHeadBean;
import com.extension.company.common.mvp.BasePresenter;
import com.extension.company.contract.main.FragmentHomeContract;
import com.extension.company.model.main.FragmentHomeMode;
import com.extension.company.view.main.FragmentHome;

import java.util.List;

/**
 * 首页的fragment p层
 */
public class FragmentHomePresenter extends BasePresenter<FragmentHomeMode, FragmentHomeContract.View> {


	@Override
	public FragmentHomeMode createModel() {
		return new FragmentHomeMode();
	}


	/**
	 * 功能：首页除列表外其他信息：轮播图，赚圈头条推荐文章 请求
	 *
	 * @param context fragmentHome的上下文
	 */
	public void requestHeader(Context context) {


		model.requestDataOne(context, new FragmentHomeContract.FragmentHomeModelCallback() {
			FragmentHome fragmentHome = (FragmentHome) getView();

			@Override
			public void banner(List<ListHeadBean.DataBean.BannerBean> list) {  // banner页回调
				if (null != getView()) {
					((FragmentHome) getView()).initBanner(list);
				}
			}

			@Override
			public void adList(List<ListHeadBean.DataBean.OtherAdBean> list) { // 三个广告页的回调
				if (null != fragmentHome) {
					fragmentHome.initImgAd(list);
				}
			}

			@Override
			public void adImage(ListHeadBean.DataBean.AdDataBean ADBean) {  // 横幅广告图片回调
				if (null != fragmentHome) {
					fragmentHome.initImgLarge(ADBean);
				}
			}

			@Override
			public void activityText(List<ListHeadBean.DataBean.FirstDataBean> list) { // 走马灯的活动通知回调
				if (null != fragmentHome) {
					fragmentHome.initHorselight(list);
				}
			}

			@Override
			public void catList(List<ListHeadBean.DataBean.CateListBean> list) {
				if (null!=fragmentHome){
					fragmentHome.initFiveItem(list);
				}
			}
		});

	}

	/**
	 * 请求热门活动 列表
	 */
	public void requestHotData() {
		model.requestHotData(new FragmentHomeContract.HotDataCallBack() {
			@Override
			public void hotList(List<HotDataListBean.DataBean.HotDataBean> hotDataBeanList) {
				if (null!=getView()){
					((FragmentHome)getView()).initHotActivity(hotDataBeanList);
				}

			}
		});

	}

	@Override
	protected void onViewDestroy() {

	}
}
